package prickworlds.game;

/**
 * Base class for every object that can move
 * 
 * @author Faruk Acibal, Richard Dziambor, Christian Holzreuter, Nicolas Winkler
 * 
 */
public abstract class MovingSolidObject extends SolidObject {
	/**
	 * the x-coordinate of the velocity
	 */
	public float velX;

	/**
	 * the y-coordinate of the velocity
	 */
	public float velY;

	/**
	 * creates a {@link MovingSolidObject} with velocity 0
	 */
	public MovingSolidObject() {
		this(0.0f, 0.0f);
	}

	/**
	 * creates a {@link MovingSolidObject} at the specified position
	 */
	public MovingSolidObject(float posX, float posY) {
		super(posX, posY);
		velX = 0.0f;
		velY = 0.0f;
	}

	/**
	 * updates position
	 */
	@Override
	public void update() {

		posX += velX;
		posY += velY;
		
		super.update();
	}

	/**
	 * adds force to the object
	 * 
	 * @param forceX
	 *            the x-value of the force vector
	 * @param forceY
	 *            the y-value of the force vector
	 */
	void addForce(float forceX, float forceY) {
		velX += forceX;
		velY += forceY;
	}
}
